package ru.st.selenium.pages;

import org.openqa.selenium.Alert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class SimpleMoviePage extends Page {

    @FindBy(xpath = "//h2")
    private WebElement movieName;

    @FindBy(xpath = "//img[@title='Remove']")
    private WebElement deleteBtn;

    public WebElement getMovieName() {
        return movieName;
    }

    public SimpleMoviePage(WebDriver webDriver) {
        super(webDriver);
    }

    public HomePage removeSimpleMovie() {
        deleteBtn.click();
        Alert alert = getWebDriver().switchTo().alert();
        alert.accept();
        return PageFactory.initElements(getWebDriver(), HomePage.class);
    }


}
